package com.example.ucs.api;

import com.example.ucs.dto.UserDTO;
import com.example.ucs.restful.APIException;
import com.example.ucs.restful.ResultCodeEnum;
import com.example.ucs.restful.ResultVO;
import com.example.ucs.util.UserTraceUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "testCase")
@RestController
public class TestApi {


    @Autowired
    private UserTraceUtil userTraceUtil;

    @GetMapping("/test")
    @ApiOperation("测试接口")
    public ResultVO test(@RequestHeader String accessToken) {
        UserDTO userDTO = userTraceUtil.getCurrentUserByAccessToken(accessToken);
        System.err.println(userDTO);
        if (userDTO == null) {
            throw new APIException(ResultCodeEnum.TOKEN_TIME_OUT);
        }

        return ResultVO.ok("测试!");
    }


}
